<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
	<%@include file="/pages/include/base-head.jsp"%>
  </head>
  <body>
		<div style="padding: 20px;">
		    <h2>Spring MVC Rest风格版 Demo</h2>
		    <hr>
		    <div style="color:red">${msg}</div>
		    <form action="${contextpath}/demo/add" method="post">
		    	<input name="id" type="hidden" value="${demo.id}" />
		    	<input name="createTime" type="hidden" value="<fmt:formatDate value="${demo.createTime}" pattern="yyyy-MM-dd HH:mm:ss" />" />
		    	
			    <table border="1" style="border-collapse:collapse;width:600px;">
			    	<tbody>
			    		<tr>
			    			<td>姓名</td>
			    			<td>
			    				<input name="name" type="text" value="${demo.name}"/>
			    			</td>
			    		</tr>
			    		<tr>
			    			<td>身高</td>
			    			<td>
			    				<input name="height" type="text" value="${demo.height}"/>cm
			    			</td>
			    		</tr>
			    		<tr>
			    			<td>生日</td>
			    			<td>
			    				<input name="birthday" type="text" value="<fmt:formatDate value="${demo.birthday}" pattern="yyyy-MM-dd" />"/> 格式:yyyy-MM-dd
			    			</td>
			    		</tr>
			    		<tr>
			    			<td>状态</td>
			    			<td>
			    				<select name="status" style="width:100px;">
			    					<option value="0" ${demo.status==0?'selected':''}>启用</option>
			    					<option value="1" ${demo.status==1?'selected':''}>禁用</option>
			    				</select>
			    			</td>
			    		</tr>
			    		<tr>
			    			<td>备注</td>
			    			<td>
			    				<textarea name="remark" rows="2" cols="30">${demo.remark}</textarea>
			    			</td>
			    		</tr>
			    		<tr>
			    			<td colspan="2" align="center">
			    				<input type="button" value="确定" onclick="add();"/>
			    			</td>
			    		</tr>
			    	</tbody>
			    </table>
		    </form>
		    <p><a href="${contextpath}/demo">&lt;&lt;返回</a></p>
		</div>
		<script type="text/javascript">
			function add() {
				$.post(window.location.href,$('form').serialize(),function(data) {
					if(data==true) {
						window.location.href='${contextpath}/demo';
					} else {
						alert('操作失败!');
					}
				},'json');
			}
		</script>
  </body>
</html>